<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>服务查询</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/reportList.css">
	
    <script src="js/jquery/3.2.1/jquery.min.js"></script>
    <!-- 插件js -->
	<script src="../js/zepto.js"></script>
	<script src="../js/sm.js" ></script>
	<script src="../js/sm-extend.js" ></script>
	<script src="../js/request.js"></script>
    <script  src="../../js/common.js"></script>
    <script src="../../jsp/js/pointlog.js"></script>
	<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>  
	<script>
	window.$$=window.Zepto = Zepto;
	</script>
  </head>
  <body>
    <div class="page">
      <header class="bar bar-nav">
        <a class="button button-link button-nav pull-left" href="javascript:window.history.back();" data-transition='slide-out'>
          <span class="icon icon-left"></span>
          返回
        </a>
        <h1 class="title">服务查询</h1>
        <div class="nav_select--more cl">
          <span class="fl">全部</span>
          <i class="icon icon-down fl"></i>
        </div>
        
        <!-- 更多时间选择 -->
        <ol class="nav_ol--time">
          <span class="ol_jiao"></span>
           <li value=""><a href="javascript:void(0);">全部</a></li>
          <li value="1"><a href="javascript:void(0);">保洁</a></li>
          <li value="3"><a href="javascript:void(0);">搬家</a></li>
          <li value="2"><a href="javascript:void(0);">维修</a></li>
        </ol>
      </header>

      <!-- 列表 -->
      <div class="L_content">
        <div class="L_content--report_block">
          <ul class="packageList">
           
          </ul>
        </div>
      </div>
    </div>
    
    <script type="text/javascript">
    var storage=window.localStorage;
    var userId = Request.queryString("userId");
    function  getUserInfo(){
    	var flag="";
    	if(storage.getItem("flag")==0) flag="租客";
    	if(storage.getItem("flag")==1) flag="房东";
    	if(storage.getItem("flag")==2) flag="管家";
    	$("#nickName").text(storage.getItem("nickName")+"("+flag+")");
    	$("#phone").text(storage.getItem("phone"));
    	$("#headimg").attr("src",storage.getItem("headimg"));
    	}
    getUserInfo();
    var path = "/LanJuPublic";
    var offset = 0;//起始页码
	var limit =10;//每页个数
	var serviceType = Request.queryString("serviceType");
	var statusArr = {
			"0":"待接单",
			"1":"等待服务",
			"2":"服务中",
			"3":"已完成",
	}
	
	$(function(){
		
		loadList();
		// 选择类型
		  $(".nav_select--more").click(function(){
		    $('.nav_ol--time').toggleClass('ol_show');
		  });
		
		$('.nav_ol--time a').click(function(){
			serviceType = $(this).parent().attr("value");
			loadList();
			$('.nav_ol--time').toggleClass('ol_show');
		  });
		 /* $("body").on('click','.appoint',function(){
			 window.location.href="serverTime.html?orderId="+id;
			// $("#appointmentTime").trigger('click');
		 }) */
	})
	
	function add0(m){return m<10?'0'+m:m }
	function getLocalTime(shijianchuo) {     
		//shijianchuo是整数，否则要parseInt转换
		var time = new Date(shijianchuo);
		var y = time.getFullYear();
		var m = time.getMonth()+1;
		var d = time.getDate();
		var h = time.getHours();
		var mm = time.getMinutes();
		var s = time.getSeconds();
		return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
    }     
	
	function loadList(){
	$$.showPreloader("加载中");
	$.ajax({
		url : path+"/service/queryPackageList.do",
		data : {
			"offset": offset,
			"limit": limit,
			"serviceType":serviceType,
			"userId" :userId
		},
		type : "GET",
		dataType : 'json',
		cache : false,
		success : function(ret){
			$$.hidePreloader();
			var html = '';
			if(ret.rows!=null && ret.rows.length>0){
				$.each(ret.rows,function(i,n){
					if(n.chargesType == 1){
					html+='<li class="report_block--li cl">';
					html+=  '<div class="report_block--li_img fl">';
					html+=' <img src="'+n.imgUrl+'" alt="">';
					html+='</div>';
					html+='<div class="report_block--li_inner fr">';
					html+='  <div class="report_block--inner_inline">';
					html+='    <span class="li_inner--span01">'+n.serviceName+'</span>';
					//html+='    <span class="li_inner--span02 fr">'+statusArr[n.status]+'</span>';
					html+='  </div>';
					html+='  <div class="report_block--inner_inline">';
					html+='    <span class="li_inner--span01">'+getLocalTime(n.createTime)+'</span>';
					if(n.chargesType == 1){
						html+='    <span class="li_inner--span02 fr">共'+parseInt(n.serviceCount)*4+'次/剩'+(n.remain==null?parseInt(n.serviceCount)*4-0:parseInt(n.serviceCount)*4-parseInt(n.remain))+'次</span>';
					}else{
						html+='    <span class="li_inner--span02 fr">共'+n.serviceCount+'次/剩'+(n.remain==null?n.serviceCount-0:n.serviceCount-n.remain)+'次</span>';
					}
					html+=' </div>';
					html+=' <div class="report_block--inner_comment cl">';
					html+=' <div class="comment--text fl">';
					html+=' <a href="serverTime.html?orderId='+n.orderId+'" class="to_comment--detail fr">预约第'+(n.done==null?1:parseInt(n.done)+1)+'次服务</a>';
					html+=' </div>';
					html+='<a href="packageDetail.html?orderId='+n.orderId+'" class="to_comment--detail fr">查看详情</a>';
					html+=' </div>';
	             html+=' </div>';
	             html+='  </li>';
					}else{
						html+='<li class="report_block--li cl">';
						html+=  '<div class="report_block--li_img fl">';
						html+=' <img src="'+n.imgUrl+'" alt="">';
						html+='</div>';
						html+='<div class="report_block--li_inner fr">';
						html+='  <div class="report_block--inner_inline">';
						html+='    <span class="li_inner--span01">'+n.serviceName+'</span>';
						//html+='    <span class="li_inner--span02 fr">'+statusArr[n.status]+'</span>';
						html+='  </div>';
						html+='  <div class="report_block--inner_inline">';
						html+='    <span class="li_inner--span01">'+getLocalTime(n.createTime)+'</span>';
						if(n.chargesType == 1){
							html+='    <span class="li_inner--span02 fr">共'+parseInt(n.serviceCount)*4+'次/剩'+(n.remain==null?parseInt(n.serviceCount)*4-0:parseInt(n.serviceCount)*4-parseInt(n.remain))+'次</span>';
						}else{
							html+='    <span class="li_inner--span02 fr">共'+n.serviceCount+'次/剩'+(n.remain==null?n.serviceCount-0:n.serviceCount-n.remain)+'次</span>';
						}
						html+=' </div>';
						html+=' <div class="report_block--inner_comment cl">';
						html+='<a href="packageDetail.html?orderId='+n.orderId+'" class="to_comment--detail fr">查看详情</a>';
						html+=' </div>';
		             html+=' </div>';
		             html+='  </li>';
					}
				});
			}else if(ret.msg!=null){
				
				    $$.alert(ret.msg, function () {
			          window.location.href="../login.html?url="+encodeURIComponent(window.location.href);
			        });
			}
			$(".packageList").html( html||'<ul><li class="report_block--li cl">暂无数据</li></ul>' );
			
		},
		error: function(){
			$$.hidePreloader();
			$$.toast("加载出错");
		}
	});
}
	function toLink(id) {
		window.location.href="packageDetail.html?serviceId="+id;
	}
</script>
  </body>
</html>